# coding=utf-8
# 学习单位  : 郑州大学
# @Author  : 铭同学
# @Time    : 2021/9/23 7:59
# @Software: PyCharm
import pandas as pd

def main():
    # .CSV后缀名结尾的需要用read_table
    data = pd.read_table('20210922234500.export.CSV', encoding='utf-8', header=None)
    # print(data.head())
    # 增加表头字段值
    names = ['GlobalEventID','Day','MonthYear','Year','FractionDate', #5

             # （2）ACTOR ATTRIBUTES
             # 参与者1
             'Actor1Code','Actor1Name','Actor1CountryCode','Actor1KnownGroupCode','Actor1EthnicCode','Actor1Religion1Code','Actor1Religion2Code','Actor1Type1Code','Actor1Type2Code','Actor1Type3Code',#10
             # 参与者2将重复以上所有属性
             'Actor2Code','Actor2Name','Actor2CountryCode','Actor2KnownGroupCode','Actor2EthnicCode','Actor2Religion1Code','Actor2Religion2Code','Actor2Type1Code','Actor2Type2Code','Actor2Type3Code',

             # （3）EVENT ACTION ATTRIBUTES
             'IsRootEvent','EventCode','EventBaseCode','EventRootCode','QuadClass','GoldsteinScale','NumMentions','NumSources','NumArticles','AvgTone', #10

             # （4）EVENT GEOGRAPHY--版本2在这里添加了3个新的字段
             # 参与者1
             'Actor1Geo_Type','Actor1Geo_Fullname','Actor1Geo_CountryCode','Actor1Geo_ADM1Code','Actor1Geo_Lat','Actor1Geo_Long','Actor1Geo_FeatureID','Actor1Geo_ADM2Code', #8
             # 参与者2
             'Actor2Geo_Type','Actor2Geo_Fullname','Actor2Geo_CountryCode','Actor2Geo_ADM1Code','Actor2Geo_Lat','Actor2Geo_Long','Actor2Geo_FeatureID','Actor2Geo_ADM2Code',
             # 这里少了一个事件event(ActionGeo)对应的各个属性值吧 #8个--暂时是凭靠推测加上去的
             'ActionGeo_Type','ActionGeo_Fullname','ActionGeo_CountryCode','ActionGeo_ADM1Code','ActionGeo_Lat','ActionGeo_Long','ActionGeo_FeatureID','ActionGeo_ADM2Code',

             # （5）DATA MANAGEMENT FIELDS
             'DATEADDED','SOURCEURL' #2

             ]
    data.columns = names
    # print(data.head())
    data.to_csv('20210922234500.export_表头0.csv', encoding='utf-8', index=False)

if __name__ == '__main__':
    pass
    main()
